﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class TestCase_TestFirstControl : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.DotNetFlexGrid2.InitConfig(
            new string[]{
                "title=标题",//标题
                "singleselected=false",//是否单选
                "resizable=true",//是否可以调整大小
                "usepager=true",//使用分页器
                "showcheckbox=true",//显示复选框
                "height=200",//高度，可为auto或具体px值
                "width=auto",//宽度，可为auto或具体px值
                "striped=true",//是否显示行交替色
                "selectedonclick=false"//是否点击行自动选中checkbox
            },
            new dotNetFlexGrid.FieldConfig[]{
                new dotNetFlexGrid.FieldConfig("Guid","编号",60,true,dotNetFlexGrid.FieldConfigAlign.Left,false,true,true),
                new dotNetFlexGrid.FieldConfig("String1","字段1",120,true,dotNetFlexGrid.FieldConfigAlign.Right),
                new dotNetFlexGrid.FieldConfig("String2","地址",180,true,dotNetFlexGrid.FieldConfigAlign.Left,false,false,true,"<div style='height:40px;'>演示模板<input id='txtAddress_[@Guid]' type='text' value='[@String2]'/><a href='[@String1]'>地址是字段1的</a></div>"),
                new dotNetFlexGrid.FieldConfig("String3","字段3",60,true,dotNetFlexGrid.FieldConfigAlign.Left),
                new dotNetFlexGrid.FieldConfig("String4","字段4",60,true,dotNetFlexGrid.FieldConfigAlign.Left),
                new dotNetFlexGrid.FieldConfig("Int1","字段5",60,true,dotNetFlexGrid.FieldConfigAlign.Left),
                new dotNetFlexGrid.FieldConfig("Int2","字段6",60,true,dotNetFlexGrid.FieldConfigAlign.Left),
                new dotNetFlexGrid.FieldConfig("DateTime","字段7",60,true,dotNetFlexGrid.FieldConfigAlign.Left),
                new dotNetFlexGrid.FieldConfig("Checked","字段8",60,false,dotNetFlexGrid.FieldConfigAlign.Left,true,true,false)
            },
            null,
            null

            );
        this.DotNetFlexGrid2.DataHandler = new dotNetFlexGrid.DataHandlerDelegate(DotNetFlexGrid1DataHandler);//绑定方法必须是public的
        this.DotNetFlexGrid2.ServerShow();

        this.DotNetFlexiGrid1.InitConfig(
            new string[]{
                "title=标题",//标题
                "singleselected=false",//是否单选
                "resizable=true",//是否可以调整大小
                "usepager=true",//使用分页器
                "showcheckbox=true",//显示复选框
                "height=200",//高度，可为auto或具体px值
                "width=auto",//宽度，可为auto或具体px值
                "striped=true",//是否显示行交替色
                "selectedonclick=true"//是否点击行自动选中checkbox
            },
            new dotNetFlexGrid.FieldConfig[]{
                new dotNetFlexGrid.FieldConfig("Guid","编号",60,true,dotNetFlexGrid.FieldConfigAlign.Left,false,true,true),
                new dotNetFlexGrid.FieldConfig("String1","字段1",120,true,dotNetFlexGrid.FieldConfigAlign.Right),
                new dotNetFlexGrid.FieldConfig("String2","字段2",60,true,dotNetFlexGrid.FieldConfigAlign.Left),
                new dotNetFlexGrid.FieldConfig("String3","字段3",60,true,dotNetFlexGrid.FieldConfigAlign.Left),
                new dotNetFlexGrid.FieldConfig("String4","字段4",60,true,dotNetFlexGrid.FieldConfigAlign.Left),
                new dotNetFlexGrid.FieldConfig("Int1","字段5",60,true,dotNetFlexGrid.FieldConfigAlign.Left),
                new dotNetFlexGrid.FieldConfig("Int2","字段6",60,true,dotNetFlexGrid.FieldConfigAlign.Left),
                new dotNetFlexGrid.FieldConfig("DateTime","字段7",60,true,dotNetFlexGrid.FieldConfigAlign.Left),
                new dotNetFlexGrid.FieldConfig("Checked","字段8",60,false,dotNetFlexGrid.FieldConfigAlign.Left,true,true,false)
            },
            new dotNetFlexGrid.SerchParamConfig[]{
                new dotNetFlexGrid.SerchParamConfig("Guid","Guid",true,dotNetFlexGrid.SerchParamConfigOperater.Like,@"^[\d]+$"),
                new dotNetFlexGrid.SerchParamConfig("String1","String1",false,dotNetFlexGrid.SerchParamConfigOperater.Like,""),
                new dotNetFlexGrid.SerchParamConfig("Checked","Checked",false,dotNetFlexGrid.SerchParamConfigOperater.Eq,"")

            },
            null

            );
        this.DotNetFlexiGrid1.DataHandler = new dotNetFlexGrid.DataHandlerDelegate(DotNetFlexGrid1DataHandler);//绑定方法必须是public的
        this.DotNetFlexiGrid1.ServerShow();
    }
    public dotNetFlexGrid.DataHandlerResult DotNetFlexGrid1DataHandler(dotNetFlexGrid.DataHandlerParams p)
    {
        
        
        return dotNetFlexGrid.DemoDataHandler(p);
    }
    private DataTable MemoryTable(int start,int num)
    {
        DataTable result = new DataTable("js_flexigrid");
        result.Columns.Add("Guid", System.Type.GetType("System.String"));
        result.Columns.Add("String1", System.Type.GetType("System.String"));
        result.Columns.Add("String2", System.Type.GetType("System.String"));
        result.Columns.Add("String3", System.Type.GetType("System.String"));
        result.Columns.Add("String4", System.Type.GetType("System.String"));
        result.Columns.Add("Int1", System.Type.GetType("System.Int32"));
        result.Columns.Add("Int2", System.Type.GetType("System.Int32"));
        result.Columns.Add("DateTime", System.Type.GetType("System.DateTime"));
        result.Columns.Add("Checked", System.Type.GetType("System.Boolean"));

        for (int i = start; i < num + start; i++)
        {
            DataRow dr = result.NewRow();

            dr["Guid"] = Guid.NewGuid().ToString();
            dr["String1"] = "字段1_" + i.ToString();
            dr["String2"] = "字段2_" + i.ToString();
            dr["String3"] = "字段3_" + i.ToString();
            dr["String4"] = "字段4_" + i.ToString();

            dr["Int1"] = 1 * 100000 + i;
            dr["Int2"] = 2 * 100000 + i;
            dr["DateTime"] = DateTime.Now;
            if(i!=start)
                dr["Checked"] = true;
            else
                dr["Checked"] = !true;


            result.Rows.Add(dr);
        }
        return result;
    }


}
